package practice.tmp;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

public class Solution24 {
    public ListNode swapPairs(ListNode head) {
        ListNode dummy = new ListNode(-1);
        dummy.next = head;
        ListNode pre = dummy;
        ListNode next;
        while (head != null && head.next != null) {
            next = head.next;
            pre.next = next;
            head.next = next.next;
            next.next = head;
            pre = head;
            head = head.next;
        }
        return dummy.next;
    }
}
